<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>ES6的函数</title>
</head>
<body>
<script>
function funcName1(x, y) {
    return x + y;
}
console.log(funcName1(2, 3)); //输出结果：5

var funcName2 = (x, y) => x + y;
console.log(funcName2(2, 3)); //输出结果：5

var funcName3 = (x, y) => {
    console.log('函数返回值：');
    return x + y;
};
console.log(funcName3(2, 3)); //输出结果：5

var funcName4 = (x, y = 5) => {
    console.log('函数返回值：');
    return x + y;
};
console.log(funcName4(2));     //第二个参数使用默认值 5。输出结果：7
console.log(funcName4(3, 6));  //输出结果：9

let x = "vue";
function funcName5(z, y = x) {
    console.log(z, y);
}
funcName5("hello");
	
function funcName6(first, second, ...arg) {
    console.log(arg.length);
}
funcName6(1, 2, 3, 4, 5, 6, 7);  //调用函数后，输出结果为5

</script>
</body>
</html>